﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using System;

public class CommonObjectPool<T> where T: new()
{
	private static readonly ObjectPool<object> s_Pool;

	static CommonObjectPool()
	{
		CommonObjectPool<T>.s_Pool = new ObjectPool<object>(new ObjectPool<object>.CreateObj(CommonObjectPool<T>.Create), null, null);
	}

	public static object Create()
	{
		return ((default(T) == null) ? Activator.CreateInstance<T>() : default(T));
	}


	public static T Get()
	{
		return (T) CommonObjectPool<T>.s_Pool.Get();
	}
		

	public static void Release(T toRelease)
	{
		CommonObjectPool<T>.s_Pool.Release(toRelease);
	}
}